package com.fire.control.system.module.device.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.fire.control.system.dto.GatewayListDTO;
import com.fire.control.system.dto.SelectGatewayDTO;
import com.fire.control.system.entity.Area;
import com.fire.control.system.entity.Gateway;

public interface GatewayMapper{
	
	/**
	 * @author: xiechengguang 
	 * @Title: getGatewayList   
	 * @Description: 通过企业id获取网关列表  
	 */
	public List<GatewayListDTO> getGatewayList(@Param("companyId") String companyId);
	
	
	/**
	 * @author: xiechengguang 
	 * @Title: searchGateways   
	 * @Description: 查询网关列表  
	 */
	public List<GatewayListDTO> searchGateways(@Param("companyId") String companyId, @Param("gatewayName") String gatewayName);
	
	
	/**
	 * @author: xiechengguang 
	 * @Title: getAreaById   
	 * @Description: TODO  
	 */
	@Select("select * from t_area a where a.id = #{id}")
	public Area getAreaById(String id);
	
	/**
	 * @author: xiechengguang 
	 * @Title: deleteById   
	 * @Description: 软删除  
	 */
	@Update("UPDATE t_gateway SET status = false WHERE id = #{id}")
	public int deleteById(String id);
	
	@Select("SELECT * FROM t_gateway WHERE status = true AND id = #{id}")
	public Gateway getById(String id);
	
	/**
	 * @author: xiechengguang 
	 * @Title: updateGateway   
	 * @Description: 更新实体  
	 */
	public int updateGateway(Gateway gateway);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getDetailById   
	 * @Description: 根据id获取网关详情  
	 */
	public GatewayListDTO getDetailById(@Param("id") String id);
	
	
	/**
	 * @author: xiechengguang 
	 * @Title: getByGroupId   
	 * @Description: 根据设备组id获取所有网关  
	 */
	@Select("SELECT id,gateway_name FROM t_gateway WHERE status = true AND device_group_id = #{groupId}")
	public List<SelectGatewayDTO> getByGroupId(String groupId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getGatewaysByTreeId   
	 * @Description: 根据省、市、区、设备组获取其下的对应设备  
	 */
	public List<GatewayListDTO> getGatewaysByTreeId(@Param("id") String id, @Param("companyIds") List<String> companyIds, @Param("gatewayName") String gatewayName);
	
}
